<div class="row">
	<div class="col-md-12">
		<form id="form">
			<input type="hidden" id="id" name="username" value=${bean.username}>
			<div class="box-body">
				<div class="form-group">
					<label>新密码</label>
					<input type="password" class="form-control" name="password" id="password" value='' placeholder="输入密码...">
				</div>
                <div class="form-group">
                    <label id="passwordLabel">确认密码</label>
                    <input type="password" class="form-control" name="agpassword" id="agpassword" value='' placeholder="再输入密码...">
                </div>
             </div>
			<div class="box-footer">
				<div class="pull-right">
					<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i>关闭</button>
					<button onclick="agPasswordUpdate();" type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i>更新</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">

    var agPasswordUpdate = function (){
        $("span").remove(".errorClass");
        $("br").remove(".errorClass");
        var status = 1;
        if($("#password").val() != $("#agpassword").val()){
            $("#passwordLabel").prepend('<span class="errorClass" style="color:red">*两次密码不相同</span><br class="errorClass"/>');
            status = 0;
        }
        if(status == 0){
            return false;
        }else{
            ajaxPost();
        }
    }


function ajaxPost(){

	$.ajax({
		url: '${ctx}/admin/user/pwdupdate',
	    type: 'post',
	    dataType: 'text',
	    data: $("#form").serialize(),
	    success: function (data) {
	    	$("#lgModal").modal('hide');
	    	alertMsg("更新成功,请重新登录","success");
	    	setTimeout('window.location.href = "/admin/logout"',2000);

	    }
	});
}

</script>